import java.util.HashMap;
import java.util.HashSet;
import java.util.concurrent.Executors;
import java.util.concurrent.ThreadPoolExecutor;

public class MyThread implements Runnable{
    private int number=0;
    @Override
    public void run() {
        while (number<200){
            synchronized (this){
                ++number;
                System.out.println(number);
                notify();
                try{
                    if(number<200){
                        wait();
                    }
                }catch (InterruptedException e){
                    e.printStackTrace();
                }
            }

        }
    }

    public static void main(String[] args) {
        MyThread thread = new MyThread();
        Thread t1 = new Thread(thread);
        Thread t2 = new Thread(thread);
        t1.start();
        t2.start();

        
    }
}
